#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int c = 0;
	int a,b;
	scanf("%d%d", &a, &b);
	if (a > b)
		c = b;
	else
		c = a;
	while (a % c != 0 || b % c != 0)
	{
		c--;
	}
	printf("%d\n", c);
	return 0;
}